from odoo import models, fields, api
from odoo import exceptions # will be used in the code
import logging
_logger = logging.getLogger(__name__)

class getPrdWizard(models.TransientModel):
    _name = 'meas.prd.wizard'
    company_id=fields.Many2one('res.company',default=lambda self: self.env.company.id) 
    prd_id=fields.Many2one('meas.prd','机号')
    prd_num=fields.Char('工程编号',related="prd_id.project")
    # prd_num=fields.Char('工程编号')
    # @api.onchange('prd_id')
    # def _onchange_prd_id(self):
    #     self.prd_num=self.env['meas.prd'].search([('prd_id','=',self.prd_id)]).project
        
    
    def get_prd_action(self):
        active_ids=self.env.context.get('active_ids')
        active_model=self.env.context.get('active_model')
        company_id=self.env.company.id
        self.env['meas.main'].search([('id','in',active_ids),('company_id','=',company_id)]).update(
            {'prd_id':self.prd_id.id})